
import { Control } from 'fabric';
import get from 'lodash/get';
import FabricImg from './FabricImg';

// 编辑控制器按钮

class TrContorls extends Control {
    constructor(options) {
        super(options);
    }

    icon: FabricImg;

    x = 0.5;
    y = -0.5;
    cursorStyle = 'crosshair';
    mouseUpHandler = (eventData, transform, x, y) => {
        const target = get(transform, ['target']);

        // 注释掉不存在的store调用
        // if (target.type === 'image') {
        //     imageModelStore.setShow(true);
        // } else if (['i-text', "IText", 'text'].includes(target.type)) {
        //     textModelStore.set({ show: true });
        // }
    }
    // actionHandler(eventData, transform, x, y) {
    // },
    render(ctx, left, top, styleOverride, fabricObject) {
        if (this.icon) {
            this.icon.set({
                originX: "center",
                originY: "center",
                left,
                top,
                // angle: fabricObject.angle
            });
            this.icon.render(ctx);
        }
    }

}

const trContorls = new TrContorls({});

export default trContorls;